package com.erp.myAdapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.erp.bean.AnZhuangZhiNanBean
import com.erp.R
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_anzhuang_zhinan.view.*

/**
 * Created by Administrator on 2018/1/20/020.
 * 作者：刘洋
 */
class AnZhuangZhiNanAdapter(var context: Context, var zhinanlist: MutableList<AnZhuangZhiNanBean>) : BaseAdapter() {
    var minflater: LayoutInflater = LayoutInflater.from(context)
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v :View
        var h : Header
        if(convertView==null){
            v=minflater.inflate(R.layout.lv_anzhuang_zhinan,null)
            h= Header(v)
            v.tag=h
        }else{
            v=convertView
            h=v.tag as Header
        }
        val zhinan =zhinanlist[position]
        Myutil.settv(zhinan.title,h.TitleTv)
        Myutil.settv(Myutil.getdata(zhinan.time),h.TimeTv)
        return v
    }

    override fun getItem(position: Int): Any = zhinanlist[position]

    override fun getItemId(position: Int): Long = position.toLong()

    override fun getCount(): Int = zhinanlist.size
    class Header(var v : View){
        val TitleTv=v.TitleTv
        val TimeTv=v.TimeTv
    }
}